package com.wh.wisdomsite.xbox.server.controller.ba;

import com.wh.wisdomsite.xbox.ba.service.ISysConfigService;
import com.wh.wisdomsite.xbox.common.Constants;
import com.wh.wisdomsite.xbox.common.reponse.CommonResult;
import com.wh.wisdomsite.xbox.common.util.ResManager;
import com.wh.wisdomsite.xbox.pojo.ba.SysConfigIn;
import com.wh.wisdomsite.xbox.utils.json.JsonUtil;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.json.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;


/**
 * 公共系统配置Controller
 * @version V1.0
 * @Package: com.wh.wisdomsite.xbox.server.controller.us
 * @author: 丁奕
 * @date: 2018-08-08 17:33
 * @Copyright 公司版权所有
 * @Company 贵州万华科技有限公司Copyright (c) 2016
 **/
@Controller
@RequestMapping(value = "/sysConfig")
public class SysConfigController {

    private static final Log logger = LogFactory.getLog(SysConfigController.class);

    @Autowired
    private ISysConfigService iSysConfigService;


    /**
     * 系统设置
     * @param request
     * @param response
     * @param sysConfigIn
     * @return
     */
    @RequestMapping(value = "/sysSetting.do", method = RequestMethod.GET)
    private void sysSetting(HttpServletRequest request, HttpServletResponse response, SysConfigIn sysConfigIn) {
        CommonResult commonResult = new CommonResult();
        try {
            logger.info("系统设置-->>开始");
            HttpSession session = request.getSession(true);
            session.setAttribute("themeStyle", sysConfigIn.getThemeStyle());
            //进行换肤更新操作
            //iSysConfigService.update()
            commonResult.setCode(Constants.CODE_SUCCESS);
            commonResult.setMessage("更换系统皮肤成功！");
            commonResult.setResult(new JSONObject());
            logger.info("系统设置-->>结束");
        } catch (Exception e) {
            e.printStackTrace();
            commonResult.setCode(Constants.CODE_FAIL);
            commonResult.setMessage("更换系统皮肤成功！");
            commonResult.setResult(new JSONObject());
            logger.error("系统设置-->>异常Exception" + e.getMessage());
        }
            ResManager.getJsonOut(response).print(JsonUtil.Json2All(commonResult));
    }







}
